/**
 * 规则管理tableOptions数据
 * Date 2023-06-23 20:48
 * 备注：
 */

import moment from 'moment'

moment.locale('zh-cn', {
  weekdays: '周日_周一_周二_周三_周四_周五_周六'.split('_')
})

export const mainTableColumns = [
  { type: 'index', label: '序号', width: 60, align: 'center' },
  { prop: 'schemeName', label: '方案名称', ellipsis: true, minWidth: 150, align: 'center' },
  { prop: 'classTypeText', label: '班次类型', minWidth: 150, align: 'center' },
  { prop: 'schemeModelText', label: '排班模式', minWidth: 150, align: 'center' },
  { prop: 'schemeObj', label: '执行人', minWidth: 150, align: 'center' },
  { prop: 'updateTime', label: '更新时间', minWidth: 150, align: 'center' },
  { prop: 'statusText', label: '状态', minWidth: 100, align: 'center' },
  { prop: 'action', label: '操作', fixed: 'right', width: 180, align: 'center' }
]

export const classDetailTableColumns = [
  { type: 'selection', label: '', width: 50, align: 'center' },
  {
    prop: 'className',
    label: '班次名称',
    ellipsis: true,
    minWidth: 100,
    align: 'center'
  },
  { prop: 'stime', label: '开始时间', minWidth: 100, align: 'center' },
  { prop: 'etime', label: '结束时间', minWidth: 100, align: 'center' }
]
export const classDetailTableColumnsOther = [
  { type: 'selection', label: '', width: 50, align: 'center' },
  {
    prop: 'className',
    label: '班次名称',
    ellipsis: true,
    minWidth: 100,
    align: 'center'
  },
]

export const scheduleDetailTableColumns = (schemeDate: string,types:string) => {
  const scheduleDetailTableColumnsTemp = [
    {
      prop: 'name',
      label: '姓名',
      ellipsis: true,
      minWidth: 100,
      fixed: true,
      align: 'center',
      day: 0,
      color: '#909399'
    },
    {
      prop: 'countWork',
      label: '已发生工时',
      ellipsis: true,
      minWidth: 95,
      fixed: true,
      align: 'center',
      day: 0,
      color: '#909399'
    },
    {
      prop: 'countPlan',
      label: '已排工时',
      ellipsis: true,
      minWidth: 80,
      fixed: true,
      align: 'center',
      day: 0,
      color: '#909399'
    }
  ]
  let startDate =null
  let endDate =null
  if(moment(new Date()).format('YYYY-MM')==schemeDate){
    if(types=='add'){
      startDate = moment(new Date()).startOf('day').add(1, 'days')
    }else{
      startDate = moment(new Date()).startOf('months')
    }
    endDate = moment(new Date()).endOf('months')
  }else{
    startDate = moment(new Date(schemeDate)).startOf('months')
    endDate = moment(new Date(schemeDate)).endOf('months')
  }
  while (startDate <= endDate) {
    const item = {
      day: Number(moment(startDate).format('D')),
      prop: 'formatDate' + moment(startDate).format('D'),
      label: moment(startDate).format('DD') + '\n' + moment(startDate).format('dddd'),
      ellipsis: true,
      minWidth: 120,
      fixed: false,
      align: 'center',
      color: '#909399',
      weekDay: moment(startDate).weekday(),
      weekDayTxt: moment(startDate).format('dddd')
    }
    if (moment(startDate).weekday() === 0 || moment(startDate).weekday() === 6) {
      item.color = '#2274e2'
    }
    scheduleDetailTableColumnsTemp.push(item)
    startDate = moment(startDate).add('days', 1)
  }
  return scheduleDetailTableColumnsTemp
}
